import safeRequest from '../server/safeRequest';
import { IRequest } from 'src/interface/IRequest';

class Request implements IRequest {
  /**
   * 通用get接口
   * @description 描述内容
   * @param {string} url 接口API
   * @param {object} params fetch相关配置项
   */
  get(url: string, params: object) {
    return safeRequest.fetch(url, {
      params,
    });
  }

  /**
   * post接口
   * @param {string} url 接口API
   * @param {object} parmas 传递的数据
   */
  post(url: string, parmas: object) {
    return safeRequest.fetch(url, {
      // headers: {
      //   'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
      //   Accept: 'application/json, */*',
      // },
      method: 'post',
      data: parmas,
    });
  }
}

export default Request;
